package org.ohuyo.libra.admin.actions;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.ohuyo.commons.org.hibernate.criterion.DetachedCriteriaEx;
import org.ohuyo.commons.org.hibernate.criterion.Page;
import org.ohuyo.commons.org.hibernate.criterion.annotation.CriteriaClass;
import org.ohuyo.commons.org.hibernate.criterion.annotation.Expression;
import org.ohuyo.commons.org.hibernate.criterion.annotation.Operator;
import org.ohuyo.libra.admin.dao.AdminDao;
import org.ohuyo.libra.server.model.table.ActionRecord;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 
 * @author rabbit
 * 
 */
@Action("/admin/actionInfo")
@Result(name = "success", location = "/admin/actionInfo.jsp")
public class ActionInfoAction extends ActionSupport {

	@CriteriaClass(clazz = ActionRecord.class)
	public class ActionDetachedCriteria extends DetachedCriteriaEx {

		/**
		 * 
		 */
		private static final long serialVersionUID = 4680931256457221650L;

		/**
		 * 
		 */
		@Expression(propertyName = "custId", operator = Operator.like)
		private String custId;
		@Expression(propertyName = "custIdType", operator = Operator.like)
		private String custIdType;
		@Expression(propertyName = "msgCode", operator = Operator.eq)
		private String msgCode;

		public String getCustId() {
			return custId;
		}

		public void setCustId(String custId) {
			this.custId = custId;
		}

		public String getCustIdType() {
			return custIdType;
		}

		public void setCustIdType(String custIdType) {
			this.custIdType = custIdType;
		}

		public String getMsgCode() {
			return msgCode;
		}

		public void setMsgCode(String msgCode) {
			this.msgCode = msgCode;
		}
	}

	private ActionDetachedCriteria condition = new ActionDetachedCriteria();

	private Page page = new Page();

	@Resource(name = "libra.admin.adminDao")
	private AdminDao adminDao;

	private List<ActionRecord> actionList;

	/**
	 * 
	 */
	private static final long serialVersionUID = -7993143495988221135L;

	public String execute() throws Exception {
		// actionList = adminDao.listAction();
		actionList = adminDao.listAction(condition, page);
		return super.execute();
	}

	public void setActionList(List<ActionRecord> actionList) {
		this.actionList = actionList;
	}

	public List<ActionRecord> getActionList() {
		return actionList;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public Page getPage() {
		return page;
	}

}
